﻿using System.Collections.Generic;
using System;
using System.Reflection;
using System.Runtime.Serialization;
using GraphMLComplexType;
using System.ComponentModel.DataAnnotations;
using System.Web.DomainServices;

namespace GraphInformation
{
    public partial class Graph
    {
        [Key]
        public Guid ID { get; set; }
        public double Width { get; set; }
        public double Height { get; set; }
        public List<GraphEdge> Edges { get; set; }
        public List<GraphElement> Vertices { get; set; }        
    }

    public partial class GraphElement
    {        
        [Key]
        public Guid ID { get; set; }
        public Guid GraphID { get; set; }
        public double x { get; set; }
        public double y { get; set; }
        public double Width { get; set; }
        public double Height { get; set; }
        public List<PairKeyValue> Keys { get; set; }
    }

    public class GraphEdge
    {
        [Key]
        public Guid ID { get; set; }
        public Guid GraphID { get; set; }
        public Guid Source { get; set; }
        public Guid Target { get; set; }
        public int Condition { get; set; }
    }

    public class PairKeyValue
    {
        [Key]
        public Guid ID { get; set; }
        public Guid ElementID { get; set; }
        public String Key { get; set; }
        public String Value { get; set; }
    }

    [MetadataType(typeof(GraphElementMetadata))]
    public partial class GraphElement
    {
        internal sealed class GraphElementMetadata
        {
            [Include]
            [Association("GraphElement_Keys", "ID", "ElementID")]
            public List<PairKeyValue> Keys;
        }
    }

    [MetadataType(typeof(GraphMetadata))]
    public partial class Graph
    {
        internal sealed class GraphMetadata
        {
            [Include]
            [Association("Graph_Edges", "ID", "GraphID")]
            public List<GraphEdge> Edges;

            [Include] 
            [Association("Graph_Vertices", "ID", "GraphID")] 
            public List<GraphElement> Vertices;
        }
    }

}